# konrad.smolinski@gmail.com
# date: 1/12/2010
# last update: 1/12/2010
#
# info:
#
#
# ------------------------------------------------------------------
# input probabilities and get rhs for inequalities
rcGetRHS <- function(dgp){
	R <- length(dgp)
	K <- ncol(dgp[[1]])

	probIdx <- rcLeaveOutToProbs(K)
	probMat <- matrix(0,ncol=R,nrow=length(probIdx))

	for(r in 1:R){
		for(i in 1:length(probIdx)){
			 probMat[i,r] <- sum(dgp[[r]][probIdx[[i]]]) 
		}
	}
	rhs <- apply(probMat,1,max)	
return(rhs)	
}
# ------------------------------------------------------------------
# Validate
codeVal <- FALSE
if(codeVal){
	cat("\n Validate: rcLetLHS() : \n\n")
		
	prm <- rcPrm() # default
	print(prm)
	K <- length(prm$xval)			
	R <- length(prm$zval)
	# DGP
	dgp <- rcDgp(prm$a,prm$b,prm$d,prm$xthres,prm$xval,prm$zval)
	rhs <- rcGetRHS(dgp)
	rhs
}

